package org.charles.zhifou.common.exception;

import lombok.Getter;
import org.charles.zhifou.common.response.ResponseCodeEnum;

/**
 * <h1>自定义异常类</h1>
 *
 * @author charles
 * @version 1.0
 */
@Getter
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private final Integer code;

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(ResponseCodeEnum responseCodeEnum) {
        super(responseCodeEnum.getValue());
        this.code = responseCodeEnum.getCode();
    }

    public BusinessException(ResponseCodeEnum responseCodeEnum, String message) {
        super(message);
        this.code = responseCodeEnum.getCode();
    }

}
